<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>演示</title>
    <link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .body-bg {
            /*background-color:rgba(252, 248, 227, 0.85);*/
        }
        .page-header {
            margin:  0;
            position: fixed;
            width: 100%;
            background-color: rgba(238, 238, 238, 1);
            left: 0;
            padding: 10px;
            font-size:28px;
            border-bottom: 1px solid #7a7a7a;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
        }
        .mt100{
            padding-top: 100px;
        }
        #scripture{
            margin-top: 65px;
        }
        #mainContent {
            display: inherit;
            font-size: 2vmax;
            padding-bottom: 100px;
        }
        #mainContent h2{
            font-size: 15vmax;
        }
        #mainContent h3{
            font-size: 10vmax;
        }
        #mainContent h4{
            font-size: 5vmax;
        }
        #mainContent h5{
            font-size: 3vmax;
        }
        #mainContent span{
            margin-right: 10px;
          }
          #mainContent  p{
            cursor: pointer;
            color: #000;
            letter-spacing: 2px;
          }
       
        .txtRed{color:red !important;}
        /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
        ::-webkit-scrollbar {
            width: 4px;
            height: 4px;
            background-color: #F5F5F5;
        }
        /*定义滚动条轨道 内阴影+圆角*/
        ::-webkit-scrollbar-track {
            -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
            background-color: #F5F5F5;
        }
        /*定义滑块 内阴影+圆角*/
        ::-webkit-scrollbar-thumb {
            -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
            background-color: #555;
        }
    </style>
</head>

<body class="body-bg">
<div class="container-fluid">
    <div class="row">
        <div id="mainContent" class="col-sm-12 col-md-12">
        </div>
    </div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script>
    var timer, scrollTop = parseInt(document.documentElement.scrollTop);
    var speed=100;
    var fontSize=2;
        
    function scrollWindow() {
        var isBottom = scrollTop >$(document).height();
        if (isBottom) {
            clearInterval(timer);
            scrollTop = 0;
        } else {
            scrollTop += 1;
            window.scrollTo(0, scrollTop);
        }
    }
    //设置演示内容
    function setContent(content) {
        scrollToTop(0, 0);
        var $content=$("#mainContent");
        $content.html(content);
        $content.find("[contenteditable=true]").removeAttr("contenteditable");

        var cH=$content.height();
        var dH=$(document).height()/2;
        $("#scripture").removeClass("mt100");
        if(cH<=dH){
            $("#scripture").addClass("mt100");
        }
    }
    function scrollToTop(){
        scrollTop=0;
        window.scrollTo(0, 0);        
    }
    function autoScroll(isScroll) {
        if(isScroll){
            timer = setInterval("scrollWindow()", speed);
        }else{
            clearInterval(timer);
        }
    }
    function scrollGoTo(top) {
        //$(window).animate({scrollTop: top}, 500);
        scrollTop=top;
        window.scrollTo(0, top);
    }

    function changeFontSize(size){
        fontSize=fontSize<2?2:fontSize<5?fontSize+size:5;
        var h5=$("#mainContent").find("p");
        h5.css("font-size",  fontSize + "vmax");
    }
    $(function () {
        if (global.opener && global.opener.currentContent) {
            setContent(global.opener.currentContent.html());
        }
        $("#mainContent").on("click","p",function(){
            $(this).toggleClass("txtRed");
        });

    });
    //以下是nwjs代码
    var gui = require('nw.gui');
    var subWin=gui.Window.get();
    subWin.changeFontSize=changeFontSize;
    subWin.autoScroll=autoScroll;
    subWin.setContent=setContent;
    subWin.scrollToTop=scrollToTop;
    subWin.scrollGoTo=scrollGoTo;
    document.addEventListener('keydown', function(e){
        if(e.which == 27){
            subWin.toggleKioskMode();
        }
    }, false);
</script>
</body>

</html>